home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / VIDEO6.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  6KB  |  227 lines

  1. ;*************************************;
  2. ; WASM Video Module, Screen Routines  ;
  3. ; By Eric Tauck                       ;
  4. ;                                     ;
  5. ; Defines:                            ;
  6. ;                                     ;
  7. ;   ScrCls  clear the whole screen    ;
  8. ;   ScrClr  clear a window            ;
  9. ;   ScrPut  copy a window to memory   ;
  10. ;   ScrGet  copy memory to a window   ;
  11. ;   ScrSiz  bytes required for window ;
  12. ;                                     ;
  13. ; Requires:                           ;
  14. ;                                     ;
  15. ;   VIDEO1.ASM                        ;
  16. ;*************************************;
  17.  
  18.         jmp     _video6_end
  19.  
  20. ;========================================
  21. ; Local routine to the screen
  22. ; coordinates.
  23. ;
  24. ; In: BH= top left row; BL= top left
  25. ;     column; CH= bottom left row; CL=
  26. ;     bottom left column.
  27. ;
  28. ; Out: AX= starting screen offset; CX=
  29. ;      columns; BL= rows; DX= offset
  30. ;      from start of row to start of
  31. ;      next row.
  32.  
  33. _vid_scraddr PROC NEAR
  34.         mov     dl, _vid_cols   ;columns per row
  35.  
  36. ;--- determine starting address
  37.  
  38.         mov     al, bh          ;starting row
  39.         mul     al, dl          ;times columns per row
  40.         add     al, bl          ;add column
  41.         adc     ah, 0           ;16 bit add
  42.         shl     ax              ;times two (for attribute/character)
  43.         add     ax, _vid_base   ;add base address
  44.  
  45. ;--- determine rows to copy
  46.  
  47.         sub     ch, bh          ;determine rows
  48.         inc     ch              ;adjust, put in BL later
  49.  
  50. ;--- determine columns
  51.  
  52.         sub     cl, bl          ;determine columns to copy
  53.         inc     cl              ;adjust, clear CH later
  54.  
  55. ;--- adjust values
  56.  
  57.         mov     bl, ch          ;row count in BL
  58.         sub     ch, ch          ;column count in CX
  59.         sub     dh, dh          ;zero high byte
  60.         shl     dx              ;offset from row to row
  61.         ret
  62.         ENDP
  63.  
  64. ;========================================
  65. ; Clear the whole screen.
  66.  
  67. ScrCls  PROC    NEAR
  68.         sub     bx, bx          ;0, 0 is upper left
  69.         mov     cl, _vid_cols
  70.         dec     cl              ;lower left column
  71.         mov     ch, _vid_rows
  72.         dec     ch              ;lower left row
  73.         call    ScrClr          ;clear screen
  74.         ret
  75.         ENDP
  76.  
  77. ;========================================
  78. ; Clear part of the screen.
  79. ;
  80. ; In: BH= top left row; BL= top left
  81. ;     column; CH= bottom left row; CL=
  82. ;     bottom left column.
  83.  
  84. ScrClr  PROC    NEAR
  85.         push    di
  86.         push    es
  87.  
  88. ;--- set up registers
  89.  
  90.         call    _vid_scraddr    ;set up registers
  91.         mov     di, ax          ;screen offset
  92.         mov     es, _vid_addrseg ;screen segment
  93.  
  94. ;--- blank each row
  95.  
  96.         cld
  97.         mov     ah, _vid_attr   ;load attribute
  98.         mov     al, ' '         ;space for blanking
  99.  
  100. _srclr1 push    cx
  101.         push    di
  102.         rep
  103.         stosw                   ;blank a row
  104.         pop     di
  105.         pop     cx
  106.         add     di, dx          ;offset to next row
  107.         dec     bl              ;decrement row count
  108.         jnz     _srclr1         ;loop back if more rows
  109.  
  110.         pop     es
  111.         pop     di
  112.         ret
  113.         ENDP
  114.  
  115. ;========================================
  116. ; Write part of the screen to memory.
  117. ;
  118. ; In: BH= top left row; BL= top left
  119. ;     column; CH= bottom left row; CL=
  120. ;     bottom left column; DX:AX=
  121. ;     destination address.
  122.  
  123. ScrGet  PROC    NEAR
  124.         push    di
  125.         push    si
  126.         push    ds
  127.         push    es
  128.  
  129. ;--- set up registers
  130.  
  131.         push    dx
  132.         push    ax
  133.         call    _vid_scraddr    ;set up registers
  134.         mov     si, ax          ;save offset
  135.         mov     ds, _vid_addrseg ;load screen segment
  136.         pop     di              ;
  137.         pop     es              ;load destination address
  138.  
  139. ;--- copy data to memory
  140.  
  141.         cld
  142.  
  143. _srget1 push    cx
  144.         push    si
  145.         rep
  146.         movsw                   ;copy a row to the memory
  147.         pop     si
  148.         pop     cx
  149.         add     si, dx          ;offset to next row
  150.         dec     bl              ;decrement row count
  151.         jnz     _srget1         ;loop back if more rows
  152.  
  153.         pop     es
  154.         pop     ds
  155.         pop     si
  156.         pop     di
  157.         ret
  158.         ENDP
  159.  
  160. ;========================================
  161. ; Write memory to the screen.
  162. ;
  163. ; In: BH= top left row; BL= top left
  164. ;     column; CH= bottom left row; CL=
  165. ;     bottom left column; DX:AX= source
  166. ;     address.
  167.  
  168. ScrPut  PROC    NEAR
  169.         push    di
  170.         push    si
  171.         push    ds
  172.         push    es
  173.  
  174. ;--- set up registers
  175.  
  176.         push    dx
  177.         push    ax
  178.         call    _vid_scraddr    ;set up registers
  179.         mov     di, ax          ;save offset
  180.         mov     es, _vid_addrseg ;load screen segment
  181.         pop     si              ;
  182.         pop     ds              ;load source address
  183.  
  184. ;--- copy data to screen
  185.  
  186.         cld
  187.  
  188. _srput1 push    cx
  189.         push    di
  190.         rep
  191.         movsw                   ;copy a row to the screen
  192.         pop     di
  193.         pop     cx
  194.         add     di, dx          ;offset to next row
  195.         dec     bl              ;decrement row count
  196.         jnz     _srput1         ;loop back if more rows
  197.  
  198.         pop     es
  199.         pop     ds
  200.         pop     si
  201.         pop     di
  202.         ret
  203.         ENDP
  204.  
  205. ;========================================
  206. ; Determine the bytes required to store
  207. ; part of the screen.
  208. ;
  209. ; In: BH= top left row; BL= top left
  210. ;     column; CH= bottom left row; CL=
  211. ;     bottom left column.
  212. ;
  213. ; Out: AX= bytes required.
  214.  
  215. ScrSiz  PROC    NEAR
  216.         mov     al, cl
  217.         sub     al, bl  ;columns
  218.         inc     al
  219.         sub     ch, bh  ;rows
  220.         inc     ch
  221.         mul     al, ch  ;total cells
  222.         shl     ax      ;times two, total bytes
  223.         ret
  224.         ENDP
  225.  
  226. _video6_end
  227.